#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 5e5+5;
int n;
int a[N], tr[N];
vector<int> v;

int bin(int x){
    return lower_bound(v.begin(), v.end(),x) - v.begin() + 1;
}

int lowbit( int x ){ return x & (-x); }

void add(int x, int k){
    for ( ; x<=n; x+=lowbit(x) ) tr[x] += k;
}

int sum( int x ){
    int res = 0;
    for ( ; x>=1; x-=lowbit(x) ) res += tr[x];
    return res;
} 

signed main(){
    cin >> n;
    for ( int i=1; i<=n; i++ ){
        cin >> a[i];
        v.push_back(a[i]);
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    int ans = 0;
    for ( int i=1; i<=n; i++ ){
        ans += sum( v.size() ) - sum( bin(a[i]) );
        add( bin(a[i]), 1 );
    }
    cout << ans << '\n';

}




